{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Directories found for nanoGPT/gpt4o-runs: 44\n",
      "Paper pdfs found for nanoGPT/gpt4o-runs: 16\n",
      "Directories found for nanoGPT/claude-runs: 50\n",
      "Paper pdfs found for nanoGPT/claude-runs: 20\n",
      "Directories found for nanoGPT/deepseek-runs: 37\n",
      "Paper pdfs found for nanoGPT/deepseek-runs: 22\n",
      "Directories found for nanoGPT/llama3.1-runs: 41\n",
      "Paper pdfs found for nanoGPT/llama3.1-runs: 21\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "import pandas as pd\n",
    "import sys\n",
    "\n",
    "sys.path.append(\"..\")\n",
    "from ai_scientist.perform_review import (\n",
    "    load_paper,\n",
    "    perform_review,\n",
    "    reviewer_system_prompt_neg,\n",
    "    neurips_form,\n",
    ")\n",
    "import os\n",
    "import openai\n",
    "\n",
    "\n",
    "paper_paths = {\n",
    "    \"gpt4o-runs\": [],\n",
    "    \"claude-runs\": [],\n",
    "    \"deepseek-runs\": [],\n",
    "    \"llama3.1-runs\": [],\n",
    "}\n",
    "\n",
    "for dir in paper_paths.keys():\n",
    "    # Get paper directories in dir\n",
    "    full_dir = os.path.join(\"nanoGPT\", dir)\n",
    "    subdirs = next(os.walk(full_dir))[1]\n",
    "    print(f\"Directories found for {full_dir}: {len(subdirs)}\")\n",
    "\n",
    "    # Check if paper exists in directory and generate txt file if so\n",
    "    paper_gen_counter = 0\n",
    "    for s_dir in subdirs:\n",
    "        paper_name = s_dir[16:]\n",
    "        if os.path.exists(f\"{full_dir}/{s_dir}/{paper_name}.pdf\"):\n",
    "            paper_paths[dir].append(f\"{full_dir}/{s_dir}/{paper_name}.pdf\")\n",
    "            paper_gen_counter += 1\n",
    "    print(f\"Paper pdfs found for {full_dir}: {paper_gen_counter}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# NanoGPT Paper Reviews"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "llm_cols = [\n",
    "    \"paper_id\",\n",
    "    \"Summary\",\n",
    "    \"Questions\",\n",
    "    \"Limitations\",\n",
    "    \"Ethical Concerns\",\n",
    "    \"Soundness\",\n",
    "    \"Presentation\",\n",
    "    \"Contribution\",\n",
    "    \"Overall\",\n",
    "    \"Confidence\",\n",
    "    \"Strengths\",\n",
    "    \"Weaknesses\",\n",
    "    \"Originality\",\n",
    "    \"Quality\",\n",
    "    \"Clarity\",\n",
    "    \"Significance\",\n",
    "    \"Decision\",\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "client = openai.Client()\n",
    "model = \"gpt-4o-2024-05-13\"\n",
    "\n",
    "num_reflections = 5\n",
    "num_fs_examples = 1\n",
    "num_reviews_ensemble = 5\n",
    "temperature = 0.1\n",
    "reviewer_system_prompt = reviewer_system_prompt_neg\n",
    "review_instruction_form = neurips_form"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Directories found for nanoGPT/llama3.1-runs: 41\n",
      "Generated txt file for nanoGPT/llama3.1-runs/20240731_212220_layerwise_learning_rates/layerwise_learning_rates.pdf\n",
      "Generated review file for nanoGPT/llama3.1-runs/20240731_212220_layerwise_learning_rates/layerwise_learning_rates.pdf\n",
      "Decision: Reject, Score: 1\n",
      "Generated txt file for nanoGPT/llama3.1-runs/20240801_061540_syntactic_complexity_aware_gpt/syntactic_complexity_aware_gpt.pdf\n",
      "Generated review file for nanoGPT/llama3.1-runs/20240801_061540_syntactic_complexity_aware_gpt/syntactic_complexity_aware_gpt.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for nanoGPT/llama3.1-runs/20240801_010354_recency_effect_gpt/recency_effect_gpt.pdf\n",
      "Generated review file for nanoGPT/llama3.1-runs/20240801_010354_recency_effect_gpt/recency_effect_gpt.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for nanoGPT/llama3.1-runs/20240801_061933_entity_relationship_gpt/entity_relationship_gpt.pdf\n",
      "Generated review file for nanoGPT/llama3.1-runs/20240801_061933_entity_relationship_gpt/entity_relationship_gpt.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for nanoGPT/llama3.1-runs/20240731_211950_adaptive_block_size/adaptive_block_size.pdf\n",
      "Generated review file for nanoGPT/llama3.1-runs/20240731_211950_adaptive_block_size/adaptive_block_size.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for nanoGPT/llama3.1-runs/20240801_014116_idiomatic_gpt/idiomatic_gpt.pdf\n",
      "Generated review file for nanoGPT/llama3.1-runs/20240801_014116_idiomatic_gpt/idiomatic_gpt.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for nanoGPT/llama3.1-runs/20240801_045953_frequency_based_forgetting_gpt/frequency_based_forgetting_gpt.pdf\n",
      "Generated review file for nanoGPT/llama3.1-runs/20240801_045953_frequency_based_forgetting_gpt/frequency_based_forgetting_gpt.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for nanoGPT/llama3.1-runs/20240731_213451_temporal_regularization/temporal_regularization.pdf\n",
      "Generated review file for nanoGPT/llama3.1-runs/20240731_213451_temporal_regularization/temporal_regularization.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for nanoGPT/llama3.1-runs/20240801_001010_availability_heuristic_gpt/availability_heuristic_gpt.pdf\n",
      "Generated review file for nanoGPT/llama3.1-runs/20240801_001010_availability_heuristic_gpt/availability_heuristic_gpt.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for nanoGPT/llama3.1-runs/20240801_034431_linguistic_difficulty_gpt/linguistic_difficulty_gpt.pdf\n",
      "Generated review file for nanoGPT/llama3.1-runs/20240801_034431_linguistic_difficulty_gpt/linguistic_difficulty_gpt.pdf\n",
      "Decision: Reject, Score: 3\n",
      "Generated txt file for nanoGPT/llama3.1-runs/20240731_212950_targeted_knowledge_distillation/targeted_knowledge_distillation.pdf\n",
      "Generated review file for nanoGPT/llama3.1-runs/20240731_212950_targeted_knowledge_distillation/targeted_knowledge_distillation.pdf\n",
      "Decision: Reject, Score: 3\n",
      "Generated txt file for nanoGPT/llama3.1-runs/20240801_000729_dual_scale_attention_gpt/dual_scale_attention_gpt.pdf\n",
      "Generated review file for nanoGPT/llama3.1-runs/20240801_000729_dual_scale_attention_gpt/dual_scale_attention_gpt.pdf\n",
      "Decision: Reject, Score: 3\n",
      "Generated txt file for nanoGPT/llama3.1-runs/20240801_083347_contrastive_forgetting_gpt/contrastive_forgetting_gpt.pdf\n",
      "Generated review file for nanoGPT/llama3.1-runs/20240801_083347_contrastive_forgetting_gpt/contrastive_forgetting_gpt.pdf\n",
      "Decision: Reject, Score: 3\n",
      "Generated txt file for nanoGPT/llama3.1-runs/20240801_075259_syntactic_complexity_aware_gpt/syntactic_complexity_aware_gpt.pdf\n",
      "Generated review file for nanoGPT/llama3.1-runs/20240801_075259_syntactic_complexity_aware_gpt/syntactic_complexity_aware_gpt.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for nanoGPT/llama3.1-runs/20240801_072244_domain_invariant_reps/domain_invariant_reps.pdf\n",
      "Generated review file for nanoGPT/llama3.1-runs/20240801_072244_domain_invariant_reps/domain_invariant_reps.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for nanoGPT/llama3.1-runs/20240731_235721_domain_adaptation_meta_learning/domain_adaptation_meta_learning.pdf\n",
      "Generated review file for nanoGPT/llama3.1-runs/20240731_235721_domain_adaptation_meta_learning/domain_adaptation_meta_learning.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for nanoGPT/llama3.1-runs/20240801_030146_selective_forgetting_gpt/selective_forgetting_gpt.pdf\n",
      "Generated review file for nanoGPT/llama3.1-runs/20240801_030146_selective_forgetting_gpt/selective_forgetting_gpt.pdf\n",
      "Decision: Reject, Score: 3\n",
      "Generated txt file for nanoGPT/llama3.1-runs/20240801_044633_availability_heuristic_gpt/availability_heuristic_gpt.pdf\n",
      "Generated review file for nanoGPT/llama3.1-runs/20240801_044633_availability_heuristic_gpt/availability_heuristic_gpt.pdf\n",
      "Decision: Reject, Score: 3\n",
      "Generated txt file for nanoGPT/llama3.1-runs/20240801_004830_interpretable_dynamic_attention_gpt/interpretable_dynamic_attention_gpt.pdf\n",
      "Generated review file for nanoGPT/llama3.1-runs/20240801_004830_interpretable_dynamic_attention_gpt/interpretable_dynamic_attention_gpt.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for nanoGPT/llama3.1-runs/20240801_041741_primacy_effect_gpt/primacy_effect_gpt.pdf\n",
      "Generated review file for nanoGPT/llama3.1-runs/20240801_041741_primacy_effect_gpt/primacy_effect_gpt.pdf\n",
      "Decision: Reject, Score: 3\n",
      "Generated txt file for nanoGPT/llama3.1-runs/20240801_042950_novelty_conditioned_gpt/novelty_conditioned_gpt.pdf\n",
      "Generated review file for nanoGPT/llama3.1-runs/20240801_042950_novelty_conditioned_gpt/novelty_conditioned_gpt.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Paper pdfs found for nanoGPT/llama3.1-runs: 21\n"
     ]
    }
   ],
   "source": [
    "paper_paths = {\n",
    "    \"gpt4o-runs\": [],\n",
    "    \"claude-runs\": [],\n",
    "    \"deepseek-runs\": [],\n",
    "    \"llama3.1-runs\": [],\n",
    "}\n",
    "\n",
    "for dir in paper_paths.keys():\n",
    "    # Get paper directories in dir\n",
    "    full_dir = os.path.join(\"nanoGPT\", dir)\n",
    "    subdirs = next(os.walk(full_dir))[1]\n",
    "    print(f\"Directories found for {full_dir}: {len(subdirs)}\")\n",
    "    rating_fname = os.path.join(\"nanoGPT\", dir + \"_ratings.csv\")\n",
    "    llm_ratings = pd.DataFrame(columns=llm_cols)\n",
    "    llm_ratings.set_index(\"paper_id\", inplace=True)\n",
    "\n",
    "    # Check if paper exists in directory and generate txt file if so\n",
    "    paper_gen_counter = 0\n",
    "    for s_dir in subdirs:\n",
    "        paper_name = s_dir[16:]\n",
    "        pdf_path = f\"{full_dir}/{s_dir}/{paper_name}.pdf\"\n",
    "        try:\n",
    "            if os.path.exists(pdf_path):\n",
    "                paper_paths[dir].append(pdf_path)\n",
    "                paper_gen_counter += 1\n",
    "                txt_path = f\"parsed_ai_papers/{full_dir}/{s_dir}.txt\"\n",
    "                os.makedirs(os.path.dirname(txt_path), exist_ok=True)\n",
    "                if not os.path.exists(txt_path):\n",
    "                    text = load_paper(pdf_path, num_pages=None)\n",
    "                    with open(txt_path, \"w\") as f:\n",
    "                        f.write(text)\n",
    "                    print(f\"Generated txt file for {pdf_path}\")\n",
    "                else:\n",
    "                    with open(txt_path, \"r\") as f:\n",
    "                        text = f.read()\n",
    "\n",
    "                review = perform_review(\n",
    "                    text,\n",
    "                    model,\n",
    "                    client,\n",
    "                    num_reflections,\n",
    "                    num_fs_examples,\n",
    "                    num_reviews_ensemble,\n",
    "                    temperature,\n",
    "                    reviewer_system_prompt=reviewer_system_prompt,\n",
    "                    review_instruction_form=review_instruction_form,\n",
    "                )\n",
    "                correct_review = sum([k in review for k in llm_cols[1:]]) == len(\n",
    "                    llm_cols[1:]\n",
    "                )\n",
    "                if correct_review:\n",
    "                    # Add the reviews to the rankings dataframe as a new row\n",
    "                    llm_ratings.loc[paper_name] = review\n",
    "                    llm_ratings.to_csv(rating_fname)\n",
    "                    print(f\"Generated review file for {pdf_path}\")\n",
    "                    print(f\"Decision: {review['Decision']}, Score: {review['Overall']}\")\n",
    "                else:\n",
    "                    print(f\"Review for {pdf_path} was incorrect\")\n",
    "        except Exception as e:\n",
    "            print(f\"Error processing {pdf_path}: {e}\")\n",
    "\n",
    "    print(f\"Paper pdfs found for {full_dir}: {paper_gen_counter}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Model gpt4o - Min: 3, Max: 5, Mean: 3.25\n",
      "Model claude - Min: 3, Max: 5, Mean: 4.05\n",
      "Model deepseek - Min: 3, Max: 4, Mean: 3.210526315789474\n",
      "Model llama3.1 - Min: 1, Max: 3, Mean: 2.3157894736842106\n"
     ]
    }
   ],
   "source": [
    "# Load dataframe with results\n",
    "all_scores = {\n",
    "    \"gpt4o\": None,\n",
    "    \"claude\": None,\n",
    "    \"deepseek\": None,\n",
    "    \"llama3.1\": None,\n",
    "}\n",
    "\n",
    "for model in all_scores.keys():\n",
    "    llm_ratings = pd.read_csv(f\"nanoGPT/{model}-runs_ratings.csv\")\n",
    "    llm_ratings.set_index(\"paper_id\", inplace=True)\n",
    "    scores = llm_ratings[\"Overall\"].tolist()\n",
    "    all_scores[model] = scores\n",
    "    print(\n",
    "        f\"Model {model} - Min: {min(scores)}, Max: {max(scores)}, Mean: {sum(scores)/len(scores)}\"\n",
    "    )"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Diffusion Paper Reviews"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Directories found for diffusion/llama3.1-runs: 31\n",
      "Paper pdfs found for diffusion/llama3.1-runs: 20\n"
     ]
    }
   ],
   "source": [
    "paper_paths = {\n",
    "    \"gpt4o-runs\": [],\n",
    "    \"claude-runs\": [],\n",
    "    \"deepseek-runs\": [],\n",
    "    \"llama3.1-runs\": [],\n",
    "}\n",
    "\n",
    "for dir in paper_paths.keys():\n",
    "    # Get paper directories in dir\n",
    "    full_dir = os.path.join(\"diffusion\", dir)\n",
    "    subdirs = next(os.walk(full_dir))[1]\n",
    "    print(f\"Directories found for {full_dir}: {len(subdirs)}\")\n",
    "\n",
    "    # Check if paper exists in directory and generate txt file if so\n",
    "    paper_gen_counter = 0\n",
    "    for s_dir in subdirs:\n",
    "        paper_name = s_dir[16:]\n",
    "        if os.path.exists(f\"{full_dir}/{s_dir}/{paper_name}.pdf\"):\n",
    "            paper_paths[dir].append(f\"{full_dir}/{s_dir}/{paper_name}.pdf\")\n",
    "            paper_gen_counter += 1\n",
    "    print(f\"Paper pdfs found for {full_dir}: {paper_gen_counter}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "diffusion/llama3.1-runs\n",
      "Directories found for diffusion/llama3.1-runs: 31\n",
      "Generated txt file for diffusion/llama3.1-runs/20240803_063127_mode_transition/mode_transition.pdf\n",
      "Generated review file for diffusion/llama3.1-runs/20240803_063127_mode_transition/mode_transition.pdf\n",
      "Decision: Reject, Score: 3\n",
      "Generated txt file for diffusion/llama3.1-runs/20240803_080530_noise_schedule_signatures/noise_schedule_signatures.pdf\n",
      "Generated review file for diffusion/llama3.1-runs/20240803_080530_noise_schedule_signatures/noise_schedule_signatures.pdf\n",
      "Decision: Reject, Score: 3\n",
      "Generated txt file for diffusion/llama3.1-runs/20240803_065703_mode_signatures/mode_signatures.pdf\n",
      "Generated review file for diffusion/llama3.1-runs/20240803_065703_mode_signatures/mode_signatures.pdf\n",
      "Decision: Reject, Score: 3\n",
      "Generated txt file for diffusion/llama3.1-runs/20240803_071635_dataset_distribution_fingerprinting/dataset_distribution_fingerprinting.pdf\n",
      "Generated review file for diffusion/llama3.1-runs/20240803_071635_dataset_distribution_fingerprinting/dataset_distribution_fingerprinting.pdf\n",
      "Decision: Reject, Score: 3\n",
      "Generated txt file for diffusion/llama3.1-runs/20240803_075145_diffusion_perturbations/diffusion_perturbations.pdf\n",
      "Generated review file for diffusion/llama3.1-runs/20240803_075145_diffusion_perturbations/diffusion_perturbations.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for diffusion/llama3.1-runs/20240803_051323_learning_rate_schedule/learning_rate_schedule.pdf\n",
      "Generated review file for diffusion/llama3.1-runs/20240803_051323_learning_rate_schedule/learning_rate_schedule.pdf\n",
      "Decision: Reject, Score: 3\n",
      "Generated txt file for diffusion/llama3.1-runs/20240803_052053_resolution_conditioned_diffusion/resolution_conditioned_diffusion.pdf\n",
      "Generated review file for diffusion/llama3.1-runs/20240803_052053_resolution_conditioned_diffusion/resolution_conditioned_diffusion.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for diffusion/llama3.1-runs/20240803_085047_noise_schedule_interpolation/noise_schedule_interpolation.pdf\n",
      "Generated review file for diffusion/llama3.1-runs/20240803_085047_noise_schedule_interpolation/noise_schedule_interpolation.pdf\n",
      "Decision: Reject, Score: 3\n",
      "Generated txt file for diffusion/llama3.1-runs/20240803_100934_noise_schedule_analysis/noise_schedule_analysis.pdf\n",
      "Generated review file for diffusion/llama3.1-runs/20240803_100934_noise_schedule_analysis/noise_schedule_analysis.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for diffusion/llama3.1-runs/20240803_084629_diffusion_model_temporal_adaptation/diffusion_model_temporal_adaptation.pdf\n",
      "Generated review file for diffusion/llama3.1-runs/20240803_084629_diffusion_model_temporal_adaptation/diffusion_model_temporal_adaptation.pdf\n",
      "Decision: Reject, Score: 1\n",
      "Generated txt file for diffusion/llama3.1-runs/20240803_085742_diffusion_model_masking/diffusion_model_masking.pdf\n",
      "Generated review file for diffusion/llama3.1-runs/20240803_085742_diffusion_model_masking/diffusion_model_masking.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for diffusion/llama3.1-runs/20240803_051553_hybrid_embedding/hybrid_embedding.pdf\n",
      "Generated review file for diffusion/llama3.1-runs/20240803_051553_hybrid_embedding/hybrid_embedding.pdf\n",
      "Decision: Reject, Score: 3\n",
      "Generated txt file for diffusion/llama3.1-runs/20240803_091633_diffusion_trajectory_quality/diffusion_trajectory_quality.pdf\n",
      "Generated review file for diffusion/llama3.1-runs/20240803_091633_diffusion_trajectory_quality/diffusion_trajectory_quality.pdf\n",
      "Decision: Reject, Score: 1\n",
      "Generated txt file for diffusion/llama3.1-runs/20240803_051823_mode_specific_diffusion/mode_specific_diffusion.pdf\n",
      "Generated review file for diffusion/llama3.1-runs/20240803_051823_mode_specific_diffusion/mode_specific_diffusion.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for diffusion/llama3.1-runs/20240803_065715_diffusion_confidence/diffusion_confidence.pdf\n",
      "Generated review file for diffusion/llama3.1-runs/20240803_065715_diffusion_confidence/diffusion_confidence.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for diffusion/llama3.1-runs/20240803_052323_geometric_constraints/geometric_constraints.pdf\n",
      "Generated review file for diffusion/llama3.1-runs/20240803_052323_geometric_constraints/geometric_constraints.pdf\n",
      "Decision: Reject, Score: 3\n",
      "Generated txt file for diffusion/llama3.1-runs/20240803_052824_dataset_agnostic_diffusion/dataset_agnostic_diffusion.pdf\n",
      "Generated review file for diffusion/llama3.1-runs/20240803_052824_dataset_agnostic_diffusion/dataset_agnostic_diffusion.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for diffusion/llama3.1-runs/20240803_054621_diffusion_trajectory_control/diffusion_trajectory_control.pdf\n",
      "Generated review file for diffusion/llama3.1-runs/20240803_054621_diffusion_trajectory_control/diffusion_trajectory_control.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for diffusion/llama3.1-runs/20240803_084148_noise_schedule_symmetry/noise_schedule_symmetry.pdf\n",
      "Generated review file for diffusion/llama3.1-runs/20240803_084148_noise_schedule_symmetry/noise_schedule_symmetry.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for diffusion/llama3.1-runs/20240803_071545_symmetry_invariant_loss/symmetry_invariant_loss.pdf\n",
      "Generated review file for diffusion/llama3.1-runs/20240803_071545_symmetry_invariant_loss/symmetry_invariant_loss.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Paper pdfs found for diffusion/llama3.1-runs: 20\n"
     ]
    }
   ],
   "source": [
    "model = \"gpt-4o-2024-05-13\"\n",
    "\n",
    "for dir in paper_paths.keys():\n",
    "    # Get paper directories in dir\n",
    "    full_dir = os.path.join(\"diffusion\", dir)\n",
    "    print(full_dir)\n",
    "    subdirs = next(os.walk(full_dir))[1]\n",
    "    print(f\"Directories found for {full_dir}: {len(subdirs)}\")\n",
    "    rating_fname = os.path.join(\"diffusion\", dir + \"_ratings.csv\")\n",
    "    llm_ratings = pd.DataFrame(columns=llm_cols)\n",
    "    llm_ratings.set_index(\"paper_id\", inplace=True)\n",
    "\n",
    "    # Check if paper exists in directory and generate txt file if so\n",
    "    paper_gen_counter = 0\n",
    "    for s_dir in subdirs:\n",
    "        paper_name = s_dir[16:]\n",
    "        pdf_path = f\"{full_dir}/{s_dir}/{paper_name}.pdf\"\n",
    "        try:\n",
    "            if os.path.exists(pdf_path):\n",
    "                paper_paths[dir].append(pdf_path)\n",
    "                paper_gen_counter += 1\n",
    "\n",
    "                txt_path = f\"parsed_ai_papers/{full_dir}/{s_dir}.txt\"\n",
    "                os.makedirs(os.path.dirname(txt_path), exist_ok=True)\n",
    "                if not os.path.exists(txt_path):\n",
    "                    text = load_paper(pdf_path, num_pages=None)\n",
    "                    with open(txt_path, \"w\") as f:\n",
    "                        f.write(text)\n",
    "                    print(f\"Generated txt file for {pdf_path}\")\n",
    "                else:\n",
    "                    with open(txt_path, \"r\") as f:\n",
    "                        text = f.read()\n",
    "                review = perform_review(\n",
    "                    text,\n",
    "                    model,\n",
    "                    client,\n",
    "                    num_reflections,\n",
    "                    num_fs_examples,\n",
    "                    num_reviews_ensemble,\n",
    "                    temperature,\n",
    "                    reviewer_system_prompt=reviewer_system_prompt,\n",
    "                    review_instruction_form=review_instruction_form,\n",
    "                )\n",
    "                correct_review = sum([k in review for k in llm_cols[1:]]) == len(\n",
    "                    llm_cols[1:]\n",
    "                )\n",
    "                if correct_review:\n",
    "                    # Add the reviews to the rankings dataframe as a new row\n",
    "                    llm_ratings.loc[paper_name] = review\n",
    "                    llm_ratings.to_csv(rating_fname)\n",
    "                    print(f\"Generated review file for {pdf_path}\")\n",
    "                    print(f\"Decision: {review['Decision']}, Score: {review['Overall']}\")\n",
    "                else:\n",
    "                    print(f\"Review for {pdf_path} was incorrect\")\n",
    "        except Exception as e:\n",
    "            print(f\"Error for {pdf_path}: {e}\")\n",
    "\n",
    "    print(f\"Paper pdfs found for {full_dir}: {paper_gen_counter}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Model gpt4o - Min: 3, Max: 5, Mean: 3.7058823529411766\n",
      "Model claude - Min: 3, Max: 6, Mean: 3.8157894736842106\n",
      "Model deepseek - Min: 3, Max: 5, Mean: 3.3214285714285716\n",
      "Model llama3.1 - Min: 1, Max: 3, Mean: 2.3\n"
     ]
    }
   ],
   "source": [
    "# Load dataframe with results\n",
    "all_scores = {\n",
    "    \"gpt4o\": None,\n",
    "    \"claude\": None,\n",
    "    \"deepseek\": None,\n",
    "    \"llama3.1\": None,\n",
    "}\n",
    "\n",
    "for model in all_scores.keys():\n",
    "    llm_ratings = pd.read_csv(f\"diffusion/{model}-runs_ratings.csv\")\n",
    "    llm_ratings.set_index(\"paper_id\", inplace=True)\n",
    "    scores = llm_ratings[\"Overall\"].tolist()\n",
    "    all_scores[model] = scores\n",
    "    print(\n",
    "        f\"Model {model} - Min: {min(scores)}, Max: {max(scores)}, Mean: {sum(scores)/len(scores)}\"\n",
    "    )"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Grokking Reviews"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Directories found for grokking/llama3.1-runs: 42\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_100036_permutation_equivariance_grokking/permutation_equivariance_grokking.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_100036_permutation_equivariance_grokking/permutation_equivariance_grokking.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_002804_math_operation_depth_grokking/math_operation_depth_grokking.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_002804_math_operation_depth_grokking/math_operation_depth_grokking.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_080426_hierarchical_meta_pattern_grokking/hierarchical_meta_pattern_grokking.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_080426_hierarchical_meta_pattern_grokking/hierarchical_meta_pattern_grokking.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_072525_structured_irrelevant_info_grokking/structured_irrelevant_info_grokking.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_072525_structured_irrelevant_info_grokking/structured_irrelevant_info_grokking.pdf\n",
      "Decision: Reject, Score: 1\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_094851_controlled_concept_drift_grokking/controlled_concept_drift_grokking.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_094851_controlled_concept_drift_grokking/controlled_concept_drift_grokking.pdf\n",
      "Decision: Reject, Score: 3\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_145029_hierarchical_math_operations/hierarchical_math_operations.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_145029_hierarchical_math_operations/hierarchical_math_operations.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_102104_operation_invariance/operation_invariance.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_102104_operation_invariance/operation_invariance.pdf\n",
      "Decision: Reject, Score: 1\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_003304_missing_operand_grokking/missing_operand_grokking.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_003304_missing_operand_grokking/missing_operand_grokking.pdf\n",
      "Decision: Reject, Score: 3\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_175803_arithmetic_decomposition/arithmetic_decomposition.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_175803_arithmetic_decomposition/arithmetic_decomposition.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_040654_hierarchical_math_operations/hierarchical_math_operations.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_040654_hierarchical_math_operations/hierarchical_math_operations.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_002303_numbering_system_grokking/numbering_system_grokking.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_002303_numbering_system_grokking/numbering_system_grokking.pdf\n",
      "Decision: Reject, Score: 3\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_132224_modular_to_nonmodular_grokking/modular_to_nonmodular_grokking.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_132224_modular_to_nonmodular_grokking/modular_to_nonmodular_grokking.pdf\n",
      "Decision: Reject, Score: 3\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_103132_cognitive_demand_generalization/cognitive_demand_generalization.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_103132_cognitive_demand_generalization/cognitive_demand_generalization.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_132853_math_operation_representation_comparison/math_operation_representation_comparison.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_132853_math_operation_representation_comparison/math_operation_representation_comparison.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_104541_operation_compositionality_grokking/operation_compositionality_grokking.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_104541_operation_compositionality_grokking/operation_compositionality_grokking.pdf\n",
      "Decision: Reject, Score: 1\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_032142_identity_element_grokking/identity_element_grokking.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_032142_identity_element_grokking/identity_element_grokking.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_003034_graph_structure_grokking/graph_structure_grokking.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_003034_graph_structure_grokking/graph_structure_grokking.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_070827_distracting_patterns_grokking/distracting_patterns_grokking.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_070827_distracting_patterns_grokking/distracting_patterns_grokking.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_043727_few_shot_grokking/few_shot_grokking.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_043727_few_shot_grokking/few_shot_grokking.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_004309_operation_representation_networks/operation_representation_networks.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_004309_operation_representation_networks/operation_representation_networks.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_042456_arithmetic_decomposition/arithmetic_decomposition.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_042456_arithmetic_decomposition/arithmetic_decomposition.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_060902_nested_operations/nested_operations.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_060902_nested_operations/nested_operations.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_061539_isomorphic_grokking/isomorphic_grokking.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_061539_isomorphic_grokking/isomorphic_grokking.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_104945_model_capacity_grokking/model_capacity_grokking.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_104945_model_capacity_grokking/model_capacity_grokking.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_033537_distracting_patterns_grokking/distracting_patterns_grokking.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_033537_distracting_patterns_grokking/distracting_patterns_grokking.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_002533_rotational_symmetry_grokking/rotational_symmetry_grokking.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_002533_rotational_symmetry_grokking/rotational_symmetry_grokking.pdf\n",
      "Decision: Reject, Score: 1\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_131714_fractal_operations_grokking/fractal_operations_grokking.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_131714_fractal_operations_grokking/fractal_operations_grokking.pdf\n",
      "Decision: Reject, Score: 1\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_025747_abstractness_grokking/abstractness_grokking.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_025747_abstractness_grokking/abstractness_grokking.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_114200_operation_complexity_generalization/operation_complexity_generalization.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_114200_operation_complexity_generalization/operation_complexity_generalization.pdf\n",
      "Decision: Reject, Score: 3\n",
      "Generated txt file for grokking/llama3.1-runs/20240803_063216_abstract_algebra_grokking/abstract_algebra_grokking.pdf\n",
      "Generated review file for grokking/llama3.1-runs/20240803_063216_abstract_algebra_grokking/abstract_algebra_grokking.pdf\n",
      "Decision: Reject, Score: 2\n",
      "Paper pdfs found for grokking/llama3.1-runs: 30\n"
     ]
    }
   ],
   "source": [
    "paper_paths = {\n",
    "    \"gpt4o-runs\": [],\n",
    "    \"claude-runs\": [],\n",
    "    \"deepseek-runs\": [],\n",
    "    \"llama3.1-runs\": [],\n",
    "}\n",
    "\n",
    "model = \"gpt-4o-2024-05-13\"\n",
    "\n",
    "for dir in paper_paths.keys():\n",
    "    # Get paper directories in dir\n",
    "    full_dir = os.path.join(\"grokking\", dir)\n",
    "    subdirs = next(os.walk(full_dir))[1]\n",
    "    print(f\"Directories found for {full_dir}: {len(subdirs)}\")\n",
    "    rating_fname = os.path.join(\"grokking\", dir + \"_ratings.csv\")\n",
    "    llm_ratings = pd.DataFrame(columns=llm_cols)\n",
    "    llm_ratings.set_index(\"paper_id\", inplace=True)\n",
    "\n",
    "    # Check if paper exists in directory and generate txt file if so\n",
    "    paper_gen_counter = 0\n",
    "    for s_dir in subdirs:\n",
    "        paper_name = s_dir[16:]\n",
    "        pdf_path = f\"{full_dir}/{s_dir}/{paper_name}.pdf\"\n",
    "        try:\n",
    "            if os.path.exists(pdf_path):\n",
    "                paper_paths[dir].append(pdf_path)\n",
    "                paper_gen_counter += 1\n",
    "\n",
    "                txt_path = f\"parsed_ai_papers/{full_dir}/{s_dir}.txt\"\n",
    "                os.makedirs(os.path.dirname(txt_path), exist_ok=True)\n",
    "                if not os.path.exists(txt_path):\n",
    "                    text = load_paper(pdf_path, num_pages=None)\n",
    "                    with open(txt_path, \"w\") as f:\n",
    "                        f.write(text)\n",
    "                    print(f\"Generated txt file for {pdf_path}\")\n",
    "                else:\n",
    "                    with open(txt_path, \"r\") as f:\n",
    "                        text = f.read()\n",
    "                review = perform_review(\n",
    "                    text,\n",
    "                    model,\n",
    "                    client,\n",
    "                    num_reflections,\n",
    "                    num_fs_examples,\n",
    "                    num_reviews_ensemble,\n",
    "                    temperature,\n",
    "                    reviewer_system_prompt=reviewer_system_prompt,\n",
    "                    review_instruction_form=review_instruction_form,\n",
    "                )\n",
    "                correct_review = sum([k in review for k in llm_cols[1:]]) == len(\n",
    "                    llm_cols[1:]\n",
    "                )\n",
    "                if correct_review:\n",
    "                    # Add the reviews to the rankings dataframe as a new row\n",
    "                    llm_ratings.loc[paper_name] = review\n",
    "                    llm_ratings.to_csv(rating_fname)\n",
    "                    print(f\"Generated review file for {pdf_path}\")\n",
    "                    print(f\"Decision: {review['Decision']}, Score: {review['Overall']}\")\n",
    "                else:\n",
    "                    print(f\"Review for {pdf_path} was incorrect\")\n",
    "        except Exception as e:\n",
    "            print(f\"Error for {pdf_path}: {e}\")\n",
    "\n",
    "    print(f\"Paper pdfs found for {full_dir}: {paper_gen_counter}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Model gpt4o - Min: 2, Max: 3, Mean: 2.9166666666666665\n",
      "Model claude - Min: 3, Max: 5, Mean: 3.44\n",
      "Model deepseek - Min: 3, Max: 4, Mean: 3.125\n",
      "Model llama3.1 - Min: 1, Max: 3, Mean: 2.0\n"
     ]
    }
   ],
   "source": [
    "# Load dataframe with results\n",
    "all_scores = {\n",
    "    \"gpt4o\": None,\n",
    "    \"claude\": None,\n",
    "    \"deepseek\": None,\n",
    "    \"llama3.1\": None,\n",
    "}\n",
    "\n",
    "for model in all_scores.keys():\n",
    "    llm_ratings = pd.read_csv(f\"grokking/{model}-runs_ratings.csv\")\n",
    "    llm_ratings.set_index(\"paper_id\", inplace=True)\n",
    "    scores = llm_ratings[\"Overall\"].tolist()\n",
    "    all_scores[model] = scores\n",
    "    print(\n",
    "        f\"Model {model} - Min: {min(scores)}, Max: {max(scores)}, Mean: {sum(scores)/len(scores)}\"\n",
    "    )"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Manual Paper Reviews"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Directories found for manual_papers: 6\n",
      "{'Summary': 'The paper introduces an adaptive dual-scale denoising approach for low-dimensional diffusion models, aiming to balance global structure and local details in generated samples. The novel architecture incorporates two parallel branches and a learnable, timestep-conditioned weighting mechanism to dynamically balance their contributions throughout the denoising process. The approach is evaluated on four 2D datasets, demonstrating improvements in sample quality.', 'Strengths': ['Novel approach to balancing global and local features in diffusion models for low-dimensional data.', 'Comprehensive empirical evaluation on multiple 2D datasets.', 'Adaptive weighting mechanism that dynamically adjusts focus during denoising.'], 'Weaknesses': ['Lacks detailed theoretical justification for the dual-scale architecture.', 'Computational cost is significantly higher, which may limit practical applicability.', 'Some sections are not clearly explained, such as the autoencoder aggregator and weight evolution analysis.', 'Limited diversity in the datasets used for evaluation. More complex, real-world datasets could strengthen claims.', 'Insufficient ablation studies and analysis on specific design choices like different types of aggregators.'], 'Originality': 4, 'Quality': 3, 'Clarity': 3, 'Significance': 3, 'Questions': ['Can you provide a more detailed theoretical justification for the dual-scale architecture?', \"What impact do different types of aggregators have on the model's performance?\", 'How does the model perform on more complex, real-world low-dimensional datasets?', 'Can the computational cost be reduced without sacrificing performance?'], 'Limitations': ['The paper should address the high computational cost and explore ways to optimize it.', 'The limited diversity of datasets and lack of detailed theoretical backing for the proposed architecture are notable limitations.'], 'Ethical Concerns': False, 'Soundness': 3, 'Presentation': 3, 'Contribution': 3, 'Overall': 5, 'Confidence': 4, 'Decision': 'Reject'}\n",
      "Generated review txt file for manual_papers/20240802_090035_adaptive_dual_scale_denoising/adaptive_dual_scale_denoising.pdf\n",
      "Generated review file for manual_papers/20240802_090035_adaptive_dual_scale_denoising/adaptive_dual_scale_denoising.pdf\n",
      "Decision: Reject, Score: 5\n",
      "{'Summary': 'The paper proposes a novel layer-wise learning rate strategy to accelerate and enhance the grokking phenomenon in Transformer models. The approach involves assigning different learning rates to the embedding layers, lower Transformer layers, and higher Transformer layers. The method is empirically validated on algorithmic tasks such as modular arithmetic and permutations, showing significant improvements in convergence speed and final performance.', 'Strengths': ['The paper addresses an important problem in deep learning: the grokking phenomenon.', 'The proposed layer-wise learning rate strategy is novel and shows significant improvements in experimental results.', 'Experiments demonstrate substantial improvements in both convergence speed and final performance.'], 'Weaknesses': ['The paper lacks detailed methodological clarity, particularly regarding the exact implementation of the layer-wise learning rates and hyperparameter tuning.', 'The theoretical explanation for why layer-wise learning rates work is insufficient.', 'The scope of tasks is limited to algorithmic ones, making it unclear how well the findings generalize to other domains.', 'The choice of learning rates seems arbitrary and lacks justification.', 'More comprehensive ablation studies and comparisons with other related methods would strengthen the paper.', 'Certain sections, such as the experimental setup and ablation studies, could be more detailed and clearer.'], 'Originality': 3, 'Quality': 2, 'Clarity': 3, 'Significance': 3, 'Questions': ['Can the authors provide more detailed explanations of the hyperparameter tuning process and the exact implementation of the layer-wise learning rates?', 'How do the authors ensure that the proposed method generalizes to tasks beyond the algorithmic ones tested in the paper?', 'Can the authors compare their approach with other related methods in more detail?', 'Can you provide more theoretical insights into why layer-wise learning rates specifically facilitate grokking?', 'How were the specific learning rates chosen for embedding, lower, and higher layers?', 'Can you discuss the potential for overfitting and how it was mitigated?', 'Have you tested the robustness of your method across different datasets and larger model sizes?', 'What is the impact of different learning rate configurations on the results?', 'Can the authors discuss potential strategies for mitigating the need for careful tuning of learning rates to avoid instability?'], 'Limitations': ['The methodology lacks detailed clarity, and the authors do not provide sufficient information on the hyperparameter tuning process.', 'The scope of tasks is limited to algorithmic ones, and the generalizability of the findings is unclear.', 'The paper requires more theoretical backing for the proposed method.', 'The choice of specific learning rates and potential overfitting issues need to be addressed in more detail.', 'The scalability of the approach to larger models and more complex tasks is not thoroughly addressed.', 'Ethical concerns related to the potential misuse of accelerated learning techniques are not addressed.'], 'Ethical Concerns': False, 'Soundness': 2, 'Presentation': 2, 'Contribution': 3, 'Overall': 4, 'Confidence': 4, 'Decision': 'Reject'}\n",
      "Generated review txt file for manual_papers/20240801_032548_layerwise_lr_grokking/layerwise_lr_grokking.pdf\n",
      "Generated review file for manual_papers/20240801_032548_layerwise_lr_grokking/layerwise_lr_grokking.pdf\n",
      "Decision: Reject, Score: 4\n",
      "{'Summary': 'The paper introduces the Multi-Style Adapter, which enhances style awareness and consistency in character-level language models by integrating learnable style embeddings, a style classification head, and a StyleAdapter module into the GPT architecture. The approach aims to balance style adaptation and language modeling capabilities, and demonstrates improved style consistency and competitive validation losses across multiple datasets.', 'Strengths': ['The paper presents a novel approach to style-aware language modeling, addressing a critical need for fine-grained stylistic control.', 'The Multi-Style Adapter is well-motivated and integrates seamlessly with the GPT architecture.', 'Extensive experiments on diverse datasets demonstrate improved style consistency and validation loss.', 'The paper includes thorough analysis and visualization of learned style embeddings and attention patterns.'], 'Weaknesses': ['The model achieves perfect style consistency scores on some datasets, which may indicate overfitting to specific style patterns.', 'The reduced inference speed (approximately 40% slower than the baseline) may limit the practical applicability of the model.', 'The paper could explore more sophisticated style representation techniques and evaluate their impact.', 'Lack of detailed ablation studies and additional baselines to strengthen the claims.', 'Clarity of the autoencoder aggregator mechanism could be enhanced.'], 'Originality': 3, 'Quality': 3, 'Clarity': 3, 'Significance': 3, 'Questions': ['How does the model handle unseen styles during inference?', 'Can the authors provide more details on the training process and hyperparameter tuning?', \"What are the potential impacts of overfitting on the model's ability to generate diverse text within each style?\", 'Can the authors provide more detailed ablation studies, especially focusing on the impact of different components in the Multi-Style Adapter?', 'How does the Multi-Style Adapter perform compared to other recent style-transfer models?', 'Can the computational efficiency trade-offs be quantified in a more detailed manner?', \"Can the authors clarify the autoencoder aggregator's role and how it integrates with the rest of the model?\", 'What measures have been taken to ensure the model does not overfit to specific style patterns, especially given the perfect consistency scores on some datasets?', 'Are there any potential optimization techniques that could be explored to improve the computational efficiency of the Multi-Style Adapter?', 'How does the model handle cases where the input sequence contains mixed styles?', 'Could you provide more qualitative examples of generated text to demonstrate the style consistency?', 'What is the impact of reducing the number of gating parameters in the modulation function?'], 'Limitations': [\"The reduced inference speed and potential overfitting to specific style patterns are significant limitations. Future work should focus on optimizing computational efficiency and improving the model's ability to generalize to diverse styles.\", 'The paper currently lacks sufficient ablation studies and additional baselines.', \"The model's performance may be sensitive to hyperparameter settings, such as the weight of the style loss and the frequency of StyleAdapter application.\"], 'Ethical Concerns': False, 'Soundness': 3, 'Presentation': 3, 'Contribution': 3, 'Overall': 5, 'Confidence': 4, 'Decision': 'Reject'}\n",
      "Generated review txt file for manual_papers/20240727_060642_multi_style_adapter/multi_style_adapter.pdf\n",
      "Generated review file for manual_papers/20240727_060642_multi_style_adapter/multi_style_adapter.pdf\n",
      "Decision: Reject, Score: 5\n",
      "{'Summary': 'The paper explores the application of Q-learning to dynamically adjust the learning rate during transformer model training, aiming to enhance training efficiency and model performance. The state is represented by the validation loss and current learning rate, and the Q-learning agent learns to adjust the learning rate to optimize the training process. The approach is validated on three datasets: shakespeare_char, enwik8, and text8.', 'Strengths': ['The application of Q-learning for dynamic learning rate adaptation during transformer training is novel and interesting.', 'The paper addresses an important problem in neural network training: the selection of an appropriate learning rate schedule.', 'Comprehensive experimental setup on multiple datasets.'], 'Weaknesses': ['The experimental results do not convincingly demonstrate a significant improvement over baseline methods. The best validation loss achieved by the Q-learning method on the shakespeare_char dataset is worse than the baseline.', 'The choice of state representation (validation loss and current learning rate) is not well-justified.', 'The paper lacks a detailed comparison with other sophisticated adaptive learning rate methods like AdamW, LAMB, Lookahead, or Noisy Adam.', 'The clarity of the explanation on Q-learning and the reward signal could be improved.', 'The technical details of the Q-learning implementation and its integration with transformer training are not thoroughly explained.', 'The significance of the results is questionable given the additional complexity introduced by the Q-learning agent.', 'The figures and tables are not clear and do not provide sufficient insight into the benefits of the proposed method.', 'The paper does not sufficiently address the limitations of the proposed method, such as sensitivity to hyperparameters and potential overhead from the Q-learning agent.', 'The discussion on the broader impacts and potential applications of the approach is limited.'], 'Originality': 2, 'Quality': 2, 'Clarity': 2, 'Significance': 2, 'Questions': ['Can you provide a detailed justification for the choice of state representation (validation loss and current learning rate)?', 'How does your method compare with other adaptive learning rate methods like AdamW, LAMB, Lookahead, or Noisy Adam in terms of both performance and computational overhead?', 'Can you clarify the reward signal used in your Q-learning approach?', 'Why were other RL approaches not considered or compared with Q-learning?', 'Can the authors provide more details on the hyperparameter tuning process?', 'Can the authors provide more details on the state and action space used in Q-learning?', 'How sensitive is the approach to the choice of hyperparameters for Q-learning?', 'Can the authors provide a more in-depth analysis of why Q-learning leads to better performance?', 'Can you provide more details on the implementation of the Q-learning agent and its interaction with the training process?', 'What specific benefits does Q-learning offer over other RL-based hyperparameter optimization methods?', 'Can you elaborate on the marginal improvements in validation loss? Why are the differences so small?', 'How does the proposed method generalize to other types of neural network architectures or other hyperparameters?', 'Can the authors provide more insights into the robustness and generality of the proposed Q-learning based approach?', 'How does the method perform on other types of neural network architectures apart from transformers?', 'Can the authors discuss potential limitations and ethical concerns in more detail?'], 'Limitations': [\"The method's performance is sensitive to the choice of hyperparameters, and there is additional overhead introduced by the Q-learning agent.\", 'The experimental results do not convincingly demonstrate significant improvements over baseline methods.', 'The approach may not generalize well to other types of neural network architectures without further tuning.', 'The authors should discuss the potential drawbacks and challenges of using Q-learning for learning rate adaptation in more detail.', 'The paper does not adequately address the potential limitations and ethical concerns of the proposed approach. It is important to discuss how the method scales to other neural network architectures and the potential risks associated with its use.'], 'Ethical Concerns': False, 'Soundness': 2, 'Presentation': 2, 'Contribution': 2, 'Overall': 3, 'Confidence': 4, 'Decision': 'Reject'}\n",
      "Generated review txt file for manual_papers/20240725_214144_rl_lr_adaptation/rl_lr_adaptation.pdf\n",
      "Generated review file for manual_papers/20240725_214144_rl_lr_adaptation/rl_lr_adaptation.pdf\n",
      "Decision: Reject, Score: 3\n",
      "{'Summary': 'The paper investigates the impact of weight initialization strategies on the grokking phenomenon in Transformer models, focusing on arithmetic tasks in finite fields. It compares five initialization methods (PyTorch default, Xavier, He, Orthogonal, and Kaiming Normal) using a small Transformer architecture. The study reveals significant differences in convergence speed and generalization capabilities across initialization strategies, with Xavier and Orthogonal initializations showing superior performance.', 'Strengths': ['Addresses an intriguing and underexplored phenomenon in deep learning.', 'Provides a systematic comparison of multiple weight initialization strategies.', 'Includes rigorous empirical analysis and statistical validation.', 'Offers practical guidelines for initialization in similar learning scenarios.'], 'Weaknesses': ['The scope is limited to small Transformer models and arithmetic tasks, which may not generalize well to larger models or more complex tasks.', 'The paper lacks deeper theoretical insights into why certain initialization strategies perform better.', 'The clarity of the experimental setup and the integration of figures and tables could be improved.', 'The implications for broader Transformer applications and potential societal impacts are not sufficiently addressed.'], 'Originality': 3, 'Quality': 3, 'Clarity': 3, 'Significance': 3, 'Questions': ['Can the authors provide more theoretical explanations for why certain initialization methods perform better?', 'How do the findings translate to more complex, real-world tasks beyond simple arithmetic operations?', 'Can the clarity of the figures and tables be improved, and can key graphs be better integrated into the text?', 'What are the potential negative societal impacts of the findings?'], 'Limitations': ['The study is limited to small Transformer models and arithmetic tasks, which may not fully represent the complexity of real-world problems.', 'The paper lacks a deeper theoretical understanding of the observed phenomena.', 'The potential negative societal impacts of the findings are not addressed.'], 'Ethical Concerns': False, 'Soundness': 3, 'Presentation': 3, 'Contribution': 3, 'Overall': 5, 'Confidence': 4, 'Decision': 'Reject'}\n",
      "Generated review txt file for manual_papers/20240731_205208_weight_initialization_grokking/weight_initialization_grokking.pdf\n",
      "Generated review file for manual_papers/20240731_205208_weight_initialization_grokking/weight_initialization_grokking.pdf\n",
      "Decision: Reject, Score: 5\n",
      "{'Summary': 'The paper proposes integrating a Generative Adversarial Network (GAN) framework into diffusion models to improve sample quality and diversity. The approach includes a simple discriminator network, an adversarial loss term, and a gradient penalty to the adversarial loss. Extensive experiments on multiple 2D datasets are conducted to validate the approach, comparing results in terms of training time, evaluation loss, KL divergence, and sample quality.', 'Strengths': ['The integration of GAN framework with diffusion models is a novel approach to improve sample quality and diversity.', 'The introduction of a gradient penalty to improve training stability is a thoughtful addition.', 'The paper provides a comprehensive evaluation on multiple 2D datasets, using various metrics such as training time, evaluation loss, KL divergence, and sample quality.'], 'Weaknesses': ['The methodology section lacks detailed explanations for certain components, such as the exact architecture of the discriminator network and the choice of hyperparameters.', \"The improvements in evaluation loss and KL divergence are not consistent across all datasets, indicating that the model's performance may be dataset-dependent.\", \"The experimental scope is limited to 2D datasets. Further research is needed to evaluate the model's performance on higher-dimensional data.\", 'The paper lacks sufficient ablation studies to isolate the contributions of different components of the proposed method.', 'The evaluation metrics are somewhat limited; including metrics like FID could strengthen the evaluation.', 'The paper does not sufficiently address the limitations of the approach, particularly its dataset dependency and scalability to higher-dimensional data.', 'There is no discussion on potential negative societal impacts or ethical concerns related to the work.'], 'Originality': 3, 'Quality': 2, 'Clarity': 2, 'Significance': 2, 'Questions': ['Can you provide more details on the architecture of the discriminator network?', \"How do the hyperparameters λadv and λgp affect the model's performance?\", 'Can you explain why the improvements are inconsistent across different datasets?', 'Can the authors provide more detailed descriptions of the denoiser and discriminator networks?', 'Have the authors considered using more comprehensive evaluation metrics like FID?', 'Can the authors provide more ablation studies to isolate the contributions of the gradient penalty and adversarial loss?', 'How would the proposed method perform on more complex and higher-dimensional datasets?'], 'Limitations': ['The paper acknowledges the increased training time and dataset dependency of the improvements. However, it could benefit from a more thorough exploration of different architectures and higher-dimensional datasets.', \"The empirical results show mixed improvements, indicating that the model's performance may be dataset-dependent.\", 'The paper does not explore the limitations of the proposed approach in depth, particularly in terms of scalability to higher-dimensional data.'], 'Ethical Concerns': False, 'Soundness': 2, 'Presentation': 2, 'Contribution': 2, 'Overall': 3, 'Confidence': 4, 'Decision': 'Reject'}\n",
      "Generated review txt file for manual_papers/20240716_185529_gan_diffusion/gan_diffusion.pdf\n",
      "Generated review file for manual_papers/20240716_185529_gan_diffusion/gan_diffusion.pdf\n",
      "Decision: Reject, Score: 3\n",
      "Paper pdfs found for manual_papers: 6\n"
     ]
    }
   ],
   "source": [
    "import json\n",
    "\n",
    "model = \"gpt-4o-2024-05-13\"\n",
    "\n",
    "\n",
    "# Get paper directories in dir\n",
    "full_dir = \"manual_papers\"\n",
    "subdirs = next(os.walk(full_dir))[1]\n",
    "print(f\"Directories found for {full_dir}: {len(subdirs)}\")\n",
    "rating_fname = os.path.join(\"manual_papers\", \"manual_paper_ratings.csv\")\n",
    "llm_ratings = pd.DataFrame(columns=llm_cols)\n",
    "llm_ratings.set_index(\"paper_id\", inplace=True)\n",
    "\n",
    "# Check if paper exists in directory and generate txt file if so\n",
    "paper_gen_counter = 0\n",
    "for s_dir in subdirs:\n",
    "    paper_name = s_dir[16:]\n",
    "    pdf_path = f\"{full_dir}/{s_dir}/{paper_name}.pdf\"\n",
    "    try:\n",
    "        if os.path.exists(pdf_path):\n",
    "            paper_paths[dir].append(pdf_path)\n",
    "            paper_gen_counter += 1\n",
    "\n",
    "            txt_path = f\"parsed_ai_papers/{full_dir}/{s_dir}.txt\"\n",
    "            os.makedirs(os.path.dirname(txt_path), exist_ok=True)\n",
    "            if not os.path.exists(txt_path):\n",
    "                text = load_paper(pdf_path, num_pages=None)\n",
    "                with open(txt_path, \"w\") as f:\n",
    "                    f.write(text)\n",
    "                print(f\"Generated txt file for {pdf_path}\")\n",
    "            else:\n",
    "                with open(txt_path, \"r\") as f:\n",
    "                    text = f.read()\n",
    "            review = perform_review(\n",
    "                text,\n",
    "                model,\n",
    "                client,\n",
    "                num_reflections,\n",
    "                num_fs_examples,\n",
    "                num_reviews_ensemble,\n",
    "                temperature,\n",
    "                reviewer_system_prompt=reviewer_system_prompt,\n",
    "                review_instruction_form=review_instruction_form,\n",
    "            )\n",
    "            print(review)\n",
    "            with open(f\"manual_papers/{s_dir}.txt\", \"w\") as f:\n",
    "                f.write(json.dumps(review, indent=4))\n",
    "            print(f\"Generated review txt file for {pdf_path}\")\n",
    "            correct_review = sum([k in review for k in llm_cols[1:]]) == len(\n",
    "                llm_cols[1:]\n",
    "            )\n",
    "            if correct_review:\n",
    "                # Add the reviews to the rankings dataframe as a new row\n",
    "                llm_ratings.loc[paper_name] = review\n",
    "                llm_ratings.to_csv(rating_fname)\n",
    "                print(f\"Generated review file for {pdf_path}\")\n",
    "                print(f\"Decision: {review['Decision']}, Score: {review['Overall']}\")\n",
    "            else:\n",
    "                print(f\"Review for {pdf_path} was incorrect\")\n",
    "    except Exception as e:\n",
    "        print(f\"Error for {pdf_path}: {e}\")\n",
    "\n",
    "print(f\"Paper pdfs found for {full_dir}: {paper_gen_counter}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Directories found for manual_papers: 1\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Summary</th>\n",
       "      <th>Questions</th>\n",
       "      <th>Limitations</th>\n",
       "      <th>Ethical Concerns</th>\n",
       "      <th>Soundness</th>\n",
       "      <th>Presentation</th>\n",
       "      <th>Contribution</th>\n",
       "      <th>Overall</th>\n",
       "      <th>Confidence</th>\n",
       "      <th>Strengths</th>\n",
       "      <th>Weaknesses</th>\n",
       "      <th>Originality</th>\n",
       "      <th>Quality</th>\n",
       "      <th>Clarity</th>\n",
       "      <th>Significance</th>\n",
       "      <th>Decision</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>paper_id</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>adaptive_dual_scale_denoising</th>\n",
       "      <td>The paper introduces an adaptive dual-scale de...</td>\n",
       "      <td>['Can you provide a more detailed theoretical ...</td>\n",
       "      <td>['The paper should address the high computatio...</td>\n",
       "      <td>False</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>['Novel approach to balancing global and local...</td>\n",
       "      <td>['Lacks detailed theoretical justification for...</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>Reject</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>layerwise_lr_grokking</th>\n",
       "      <td>The paper proposes a novel layer-wise learning...</td>\n",
       "      <td>['Can the authors provide more detailed explan...</td>\n",
       "      <td>['The methodology lacks detailed clarity, and ...</td>\n",
       "      <td>False</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>['The paper addresses an important problem in ...</td>\n",
       "      <td>['The paper lacks detailed methodological clar...</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>Reject</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>multi_style_adapter</th>\n",
       "      <td>The paper introduces the Multi-Style Adapter, ...</td>\n",
       "      <td>['How does the model handle unseen styles duri...</td>\n",
       "      <td>[\"The reduced inference speed and potential ov...</td>\n",
       "      <td>False</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>['The paper presents a novel approach to style...</td>\n",
       "      <td>['The model achieves perfect style consistency...</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>Reject</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>rl_lr_adaptation</th>\n",
       "      <td>The paper explores the application of Q-learni...</td>\n",
       "      <td>['Can you provide a detailed justification for...</td>\n",
       "      <td>[\"The method's performance is sensitive to the...</td>\n",
       "      <td>False</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>['The application of Q-learning for dynamic le...</td>\n",
       "      <td>['The experimental results do not convincingly...</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>Reject</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>weight_initialization_grokking</th>\n",
       "      <td>The paper investigates the impact of weight in...</td>\n",
       "      <td>['Can the authors provide more theoretical exp...</td>\n",
       "      <td>['The study is limited to small Transformer mo...</td>\n",
       "      <td>False</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>['Addresses an intriguing and underexplored ph...</td>\n",
       "      <td>['The scope is limited to small Transformer mo...</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>Reject</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>gan_diffusion</th>\n",
       "      <td>The paper proposes integrating a Generative Ad...</td>\n",
       "      <td>['Can you provide more details on the architec...</td>\n",
       "      <td>['The paper acknowledges the increased trainin...</td>\n",
       "      <td>False</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>['The integration of GAN framework with diffus...</td>\n",
       "      <td>['The methodology section lacks detailed expla...</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>Reject</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>layerwise_learning_rates</th>\n",
       "      <td>The paper investigates the impact of learning ...</td>\n",
       "      <td>[\"Can you provide detailed content for the pla...</td>\n",
       "      <td>['The paper is incomplete and lacks detailed c...</td>\n",
       "      <td>False</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>['The topic of learning rate schedules is rele...</td>\n",
       "      <td>['The paper is incomplete, with missing sectio...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>Reject</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>grid_based_noise_adaptation</th>\n",
       "      <td>The paper introduces a multi-scale grid-based ...</td>\n",
       "      <td>['Can the authors provide more detailed explan...</td>\n",
       "      <td>[\"The paper does not discuss the potential soc...</td>\n",
       "      <td>False</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>['The paper addresses a relevant problem in th...</td>\n",
       "      <td>['The paper lacks clarity in some sections, es...</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>Reject</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>data_augmentation_grokking</th>\n",
       "      <td>The paper investigates the impact of data augm...</td>\n",
       "      <td>['Can the authors provide more details on the ...</td>\n",
       "      <td>[\"The paper's clarity and thoroughness in disc...</td>\n",
       "      <td>False</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>['Addresses a novel and relevant topic in deep...</td>\n",
       "      <td>['Lacks clarity in some sections, particularly...</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>Reject</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mdl_grokking_correlation</th>\n",
       "      <td>This paper investigates the phenomenon of grok...</td>\n",
       "      <td>['Can the authors provide a more detailed desc...</td>\n",
       "      <td>['The paper needs to address the clarity of th...</td>\n",
       "      <td>False</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>['The paper addresses a significant and poorly...</td>\n",
       "      <td>['The description of the weight pruning techni...</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>Reject</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                                          Summary  \\\n",
       "paper_id                                                                            \n",
       "adaptive_dual_scale_denoising   The paper introduces an adaptive dual-scale de...   \n",
       "layerwise_lr_grokking           The paper proposes a novel layer-wise learning...   \n",
       "multi_style_adapter             The paper introduces the Multi-Style Adapter, ...   \n",
       "rl_lr_adaptation                The paper explores the application of Q-learni...   \n",
       "weight_initialization_grokking  The paper investigates the impact of weight in...   \n",
       "gan_diffusion                   The paper proposes integrating a Generative Ad...   \n",
       "layerwise_learning_rates        The paper investigates the impact of learning ...   \n",
       "grid_based_noise_adaptation     The paper introduces a multi-scale grid-based ...   \n",
       "data_augmentation_grokking      The paper investigates the impact of data augm...   \n",
       "mdl_grokking_correlation        This paper investigates the phenomenon of grok...   \n",
       "\n",
       "                                                                        Questions  \\\n",
       "paper_id                                                                            \n",
       "adaptive_dual_scale_denoising   ['Can you provide a more detailed theoretical ...   \n",
       "layerwise_lr_grokking           ['Can the authors provide more detailed explan...   \n",
       "multi_style_adapter             ['How does the model handle unseen styles duri...   \n",
       "rl_lr_adaptation                ['Can you provide a detailed justification for...   \n",
       "weight_initialization_grokking  ['Can the authors provide more theoretical exp...   \n",
       "gan_diffusion                   ['Can you provide more details on the architec...   \n",
       "layerwise_learning_rates        [\"Can you provide detailed content for the pla...   \n",
       "grid_based_noise_adaptation     ['Can the authors provide more detailed explan...   \n",
       "data_augmentation_grokking      ['Can the authors provide more details on the ...   \n",
       "mdl_grokking_correlation        ['Can the authors provide a more detailed desc...   \n",
       "\n",
       "                                                                      Limitations  \\\n",
       "paper_id                                                                            \n",
       "adaptive_dual_scale_denoising   ['The paper should address the high computatio...   \n",
       "layerwise_lr_grokking           ['The methodology lacks detailed clarity, and ...   \n",
       "multi_style_adapter             [\"The reduced inference speed and potential ov...   \n",
       "rl_lr_adaptation                [\"The method's performance is sensitive to the...   \n",
       "weight_initialization_grokking  ['The study is limited to small Transformer mo...   \n",
       "gan_diffusion                   ['The paper acknowledges the increased trainin...   \n",
       "layerwise_learning_rates        ['The paper is incomplete and lacks detailed c...   \n",
       "grid_based_noise_adaptation     [\"The paper does not discuss the potential soc...   \n",
       "data_augmentation_grokking      [\"The paper's clarity and thoroughness in disc...   \n",
       "mdl_grokking_correlation        ['The paper needs to address the clarity of th...   \n",
       "\n",
       "                                Ethical Concerns  Soundness  Presentation  \\\n",
       "paper_id                                                                    \n",
       "adaptive_dual_scale_denoising              False          3             3   \n",
       "layerwise_lr_grokking                      False          2             2   \n",
       "multi_style_adapter                        False          3             3   \n",
       "rl_lr_adaptation                           False          2             2   \n",
       "weight_initialization_grokking             False          3             3   \n",
       "gan_diffusion                              False          2             2   \n",
       "layerwise_learning_rates                   False          1             1   \n",
       "grid_based_noise_adaptation                False          2             2   \n",
       "data_augmentation_grokking                 False          3             3   \n",
       "mdl_grokking_correlation                   False          2             2   \n",
       "\n",
       "                                Contribution  Overall  Confidence  \\\n",
       "paper_id                                                            \n",
       "adaptive_dual_scale_denoising              3        5           4   \n",
       "layerwise_lr_grokking                      3        4           4   \n",
       "multi_style_adapter                        3        5           4   \n",
       "rl_lr_adaptation                           2        3           4   \n",
       "weight_initialization_grokking             3        5           4   \n",
       "gan_diffusion                              2        3           4   \n",
       "layerwise_learning_rates                   1        2           4   \n",
       "grid_based_noise_adaptation                2        4           4   \n",
       "data_augmentation_grokking                 3        5           4   \n",
       "mdl_grokking_correlation                   2        3           4   \n",
       "\n",
       "                                                                        Strengths  \\\n",
       "paper_id                                                                            \n",
       "adaptive_dual_scale_denoising   ['Novel approach to balancing global and local...   \n",
       "layerwise_lr_grokking           ['The paper addresses an important problem in ...   \n",
       "multi_style_adapter             ['The paper presents a novel approach to style...   \n",
       "rl_lr_adaptation                ['The application of Q-learning for dynamic le...   \n",
       "weight_initialization_grokking  ['Addresses an intriguing and underexplored ph...   \n",
       "gan_diffusion                   ['The integration of GAN framework with diffus...   \n",
       "layerwise_learning_rates        ['The topic of learning rate schedules is rele...   \n",
       "grid_based_noise_adaptation     ['The paper addresses a relevant problem in th...   \n",
       "data_augmentation_grokking      ['Addresses a novel and relevant topic in deep...   \n",
       "mdl_grokking_correlation        ['The paper addresses a significant and poorly...   \n",
       "\n",
       "                                                                       Weaknesses  \\\n",
       "paper_id                                                                            \n",
       "adaptive_dual_scale_denoising   ['Lacks detailed theoretical justification for...   \n",
       "layerwise_lr_grokking           ['The paper lacks detailed methodological clar...   \n",
       "multi_style_adapter             ['The model achieves perfect style consistency...   \n",
       "rl_lr_adaptation                ['The experimental results do not convincingly...   \n",
       "weight_initialization_grokking  ['The scope is limited to small Transformer mo...   \n",
       "gan_diffusion                   ['The methodology section lacks detailed expla...   \n",
       "layerwise_learning_rates        ['The paper is incomplete, with missing sectio...   \n",
       "grid_based_noise_adaptation     ['The paper lacks clarity in some sections, es...   \n",
       "data_augmentation_grokking      ['Lacks clarity in some sections, particularly...   \n",
       "mdl_grokking_correlation        ['The description of the weight pruning techni...   \n",
       "\n",
       "                                Originality  Quality  Clarity  Significance  \\\n",
       "paper_id                                                                      \n",
       "adaptive_dual_scale_denoising             4        3        3             3   \n",
       "layerwise_lr_grokking                     3        2        3             3   \n",
       "multi_style_adapter                       3        3        3             3   \n",
       "rl_lr_adaptation                          2        2        2             2   \n",
       "weight_initialization_grokking            3        3        3             3   \n",
       "gan_diffusion                             3        2        2             2   \n",
       "layerwise_learning_rates                  1        1        1             1   \n",
       "grid_based_noise_adaptation               3        2        2             3   \n",
       "data_augmentation_grokking                3        3        3             3   \n",
       "mdl_grokking_correlation                  3        2        2             3   \n",
       "\n",
       "                               Decision  \n",
       "paper_id                                 \n",
       "adaptive_dual_scale_denoising    Reject  \n",
       "layerwise_lr_grokking            Reject  \n",
       "multi_style_adapter              Reject  \n",
       "rl_lr_adaptation                 Reject  \n",
       "weight_initialization_grokking   Reject  \n",
       "gan_diffusion                    Reject  \n",
       "layerwise_learning_rates         Reject  \n",
       "grid_based_noise_adaptation      Reject  \n",
       "data_augmentation_grokking       Reject  \n",
       "mdl_grokking_correlation         Reject  "
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import json\n",
    "\n",
    "model = \"gpt-4o-2024-05-13\"\n",
    "\n",
    "\n",
    "# Get paper directories in dir\n",
    "full_dir = \"manual_papers\"\n",
    "subdirs = [\n",
    "    \"20240805_071251_dual_expert_denoiser\",\n",
    "    \"20240805_104019_grid_based_noise_adaptation\",\n",
    "    \"20240804_022805_data_augmentation_grokking\",\n",
    "    \"20240804_045218_mdl_grokking_correlation\",\n",
    "]\n",
    "print(f\"Directories found for {full_dir}: {len(subdirs)}\")\n",
    "rating_fname = os.path.join(\"manual_papers\", \"manual_paper_ratings.csv\")\n",
    "\n",
    "llm_ratings = pd.read_csv(rating_fname)\n",
    "llm_ratings.set_index(\"paper_id\", inplace=True)\n",
    "llm_ratings"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "manual_papers/20240805_071251_dual_expert_denoiser/dual_expert_denoiser.pdf\n",
      "Generated txt file for manual_papers/20240805_071251_dual_expert_denoiser/dual_expert_denoiser.pdf\n",
      "{'Summary': \"The paper 'DualDiff: Enhancing Mode Capture in Low-Dimensional Diffusion Models via Dual-Expert Denoising' introduces a dual-expert denoising architecture aimed at enhancing diffusion models' performance on low-dimensional datasets. The method uses a gating mechanism to combine two specialized expert networks dynamically, which helps in capturing multiple modes in low-dimensional data distributions. The paper demonstrates substantial improvements in terms of mode capture and sample diversity, validated through various experiments on 2D datasets like 'circle', 'dino', 'line', and 'moons'.\", 'Strengths': ['The paper addresses a relevant and challenging problem in the field of generative modeling.', 'The dual-expert architecture and dynamic gating mechanism are novel and well-formulated.', \"Extensive experiments provide strong evidence of the approach's effectiveness.\", 'The introduction of a diversity loss term to encourage multiple mode capture is a valuable contribution.'], 'Weaknesses': ['The novelty of combining two expert networks with a gating mechanism is somewhat incremental.', 'The choice of datasets is limited to simple 2D shapes, which might not fully demonstrate the generalizability of the approach.', 'The evaluation of gating mechanism behavior is not sufficiently detailed.', 'The increased training and inference times are a significant drawback that may limit practical applicability.', 'The diversity loss term is weighted arbitrarily without thorough justification for the chosen value.', 'The paper lacks detailed ablation studies to isolate the impact of different components (e.g., gating mechanism, diversity loss).', 'Potential limitations and negative societal impacts are not adequately addressed.'], 'Originality': 3, 'Quality': 3, 'Clarity': 3, 'Significance': 3, 'Questions': ['Could you provide more detailed analysis on how the gating mechanism adapts during training?', 'How would the model perform on higher-dimensional datasets or more complex low-dimensional datasets?', 'Is the choice of the diversity loss weight (λ) empirically validated? Could different values lead to significantly different results?', 'Can the authors provide more details on the gating mechanism and how it determines the weight for each expert network?', 'How does the performance vary with different configurations of the gating network?', 'Can the authors explain the choice of hyperparameters, particularly the value of lambda in the diversity loss term?', 'Can the authors provide more detailed ablation studies to quantify the impact of each component (e.g., gating mechanism, diversity loss)?', 'How does the model perform with different types of aggregators for the expert networks?', 'Can more qualitative examples and visualizations be provided to substantiate the claims of improved mode capture?', 'Can you provide more details on the architecture of the expert networks and the gating mechanism?', 'How does the diversity loss term impact the final performance, and what are the trade-offs?', 'Can you include more comprehensive ablation studies to evaluate the impact of each component of the proposed method?', 'What are the computational costs associated with the dual-expert architecture, and how do they compare to the baseline?'], 'Limitations': ['The increased computational cost and the focus on low-dimensional datasets are the primary limitations of the proposed approach.', 'The generalizability to higher-dimensional settings remains unclear.', 'Potential negative societal impacts and limitations are not adequately addressed.'], 'Ethical Concerns': False, 'Soundness': 3, 'Presentation': 3, 'Contribution': 3, 'Overall': 5, 'Confidence': 4, 'Decision': 'Reject'}\n",
      "Generated review txt file for manual_papers/20240805_071251_dual_expert_denoiser/dual_expert_denoiser.pdf\n",
      "Generated review file for manual_papers/20240805_071251_dual_expert_denoiser/dual_expert_denoiser.pdf\n",
      "Decision: Reject, Score: 5\n",
      "Paper pdfs found for manual_papers: 1\n"
     ]
    }
   ],
   "source": [
    "# Check if paper exists in directory and generate txt file if so\n",
    "paper_gen_counter = 0\n",
    "for s_dir in subdirs:\n",
    "    paper_name = s_dir[16:]\n",
    "    pdf_path = f\"{full_dir}/{s_dir}/{paper_name}.pdf\"\n",
    "    print(pdf_path)\n",
    "    try:\n",
    "        if os.path.exists(pdf_path):\n",
    "            paper_paths[dir].append(pdf_path)\n",
    "            paper_gen_counter += 1\n",
    "\n",
    "            txt_path = f\"parsed_ai_papers/{full_dir}/{s_dir}.txt\"\n",
    "            os.makedirs(os.path.dirname(txt_path), exist_ok=True)\n",
    "            if not os.path.exists(txt_path):\n",
    "                text = load_paper(pdf_path, num_pages=None)\n",
    "                with open(txt_path, \"w\") as f:\n",
    "                    f.write(text)\n",
    "                print(f\"Generated txt file for {pdf_path}\")\n",
    "            else:\n",
    "                with open(txt_path, \"r\") as f:\n",
    "                    text = f.read()\n",
    "            review = perform_review(\n",
    "                text,\n",
    "                model,\n",
    "                client,\n",
    "                num_reflections,\n",
    "                num_fs_examples,\n",
    "                num_reviews_ensemble,\n",
    "                temperature,\n",
    "                reviewer_system_prompt=reviewer_system_prompt,\n",
    "                review_instruction_form=review_instruction_form,\n",
    "            )\n",
    "            print(review)\n",
    "            with open(f\"manual_papers/{s_dir}.txt\", \"w\") as f:\n",
    "                f.write(json.dumps(review, indent=4))\n",
    "            print(f\"Generated review txt file for {pdf_path}\")\n",
    "            correct_review = sum([k in review for k in llm_cols[1:]]) == len(\n",
    "                llm_cols[1:]\n",
    "            )\n",
    "            if correct_review:\n",
    "                # Add the reviews to the rankings dataframe as a new row\n",
    "                llm_ratings.loc[paper_name] = review\n",
    "                llm_ratings.to_csv(rating_fname)\n",
    "                print(f\"Generated review file for {pdf_path}\")\n",
    "                print(f\"Decision: {review['Decision']}, Score: {review['Overall']}\")\n",
    "            else:\n",
    "                print(f\"Review for {pdf_path} was incorrect\")\n",
    "    except Exception as e:\n",
    "        print(f\"Error for {pdf_path}: {e}\")\n",
    "\n",
    "print(f\"Paper pdfs found for {full_dir}: {paper_gen_counter}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "llmopt",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
